home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 August: Tool Chest / Dev.CD Aug 94.toast / New System Software Extensions / Macintosh Drag and Drop 1.1.1 / Interfaces / Drag.p < prev   
Encoding:
Text File  |  1994-04-22  |  11.3 KB  |  416 lines  |  [TEXT/MPS ]

  1. {
  2.     File:        Drag.p
  3.  
  4.     Contains:    Pascal Interface to Drag Manager
  5.  
  6.     Copyright:    © 1992-1994 by Apple Computer, Inc., all rights reserved.
  7.  
  8. }
  9.  
  10. {$IFC UNDEFINED UsingIncludes}
  11. {$SETC UsingIncludes := 0}
  12. {$ENDC}
  13.  
  14. {$IFC NOT UsingIncludes}
  15.     UNIT Drag;
  16.     INTERFACE
  17. {$ENDC}
  18.  
  19. {$IFC UNDEFINED UsingDrag}
  20. {$SETC UsingDrag := 1}
  21.  
  22. {$I+}
  23. {$SETC DragIncludes := UsingIncludes}
  24. {$SETC UsingIncludes := 1}
  25. {$IFC UNDEFINED UsingAppleEvents}
  26. {$I $$Shell(PInterfaces)AppleEvents.p}
  27. {$ENDC}
  28. {$IFC UNDEFINED UsingTextEdit}
  29. {$I $$Shell(PInterfaces)TextEdit.p}
  30. {$ENDC}
  31. {$SETC UsingIncludes := DragIncludes}
  32.  
  33.  
  34.  
  35. { Gestalt Selector and Response Constants (will move to GestaltEqu.p) }
  36.  
  37. CONST
  38.     gestaltDragMgrAttr            =    'drag';        { Drag Manager attributes }
  39.     gestaltDragMgrPresent        =    0;            { Drag Manager is present }
  40.     gestaltDragMgrFloatingWind    =    1;            { Drag Manager supports floating windows }
  41.     gestaltPPCDragLibPresent    =    2;            { Drag Manager PPC DragLib is present }
  42.  
  43.     gestaltTEAttr                =    'teat';        { TextEdit attributes }
  44.     gestaltTEHasGetHiliteRgn    =    0;            { TextEdit has TEGetHiliteRgn }
  45.  
  46.  
  47. { Flavor Flags }
  48.  
  49. CONST
  50.     flavorSenderOnly            =    $00000001;    { flavor is available to sender only }
  51.     flavorSenderTranslated        =    $00000002;    { flavor is translated by sender }
  52.     flavorNotSaved                =    $00000004;    { flavor should not be saved }
  53.     flavorSystemTranslated        =    $00000100;    { flavor is translated by system }
  54.  
  55. TYPE
  56.     FlavorFlags = LONGINT;
  57.  
  58.  
  59. { Drag Attributes }
  60.  
  61. CONST
  62.     dragHasLeftSenderWindow        =    $00000001;    { drag has left the source window since TrackDrag }
  63.     dragInsideSenderApplication    =    $00000002;    { drag is occurring within the source application }
  64.     dragInsideSenderWindow        =    $00000004;    { drag is occurring within the source window }
  65.  
  66. TYPE
  67.     DragAttributes = LONGINT;
  68.  
  69.  
  70. { Special Flavor Types }
  71.  
  72. CONST
  73.     flavorTypeHFS                =    'hfs ';        { flavor type for HFS data }
  74.     flavorTypePromiseHFS        =    'phfs';        { flavor type for promised HFS data }
  75.     flavorTypeDirectory            =    'diry';        { flavor type for AOCE directory }
  76.  
  77.  
  78. { Drag Tracking Handler Messages }
  79.  
  80. CONST
  81.     dragTrackingEnterHandler    =    1;            { drag has entered handler }
  82.     dragTrackingEnterWindow        =    2;            { drag has entered window }
  83.     dragTrackingInWindow        =    3;            { drag is moving within window }
  84.     dragTrackingLeaveWindow        =    4;            { drag has exited window }
  85.     dragTrackingLeaveHandler    =    5;            { drag has exited handler }
  86.  
  87. TYPE
  88.     DragTrackingMessage = INTEGER;
  89.  
  90.  
  91. { Drag Drawing Procedure Messages }
  92.  
  93. CONST
  94.     dragRegionBegin                =    1;            { initialize drawing }
  95.     dragRegionDraw                =    2;            { draw drag feedback }
  96.     dragRegionHide                =    3;            { hide drag feedback }
  97.     dragRegionIdle                =    4;            { drag feedback idle time }
  98.     dragRegionEnd                =    5;            { end of drawing }
  99.  
  100. TYPE
  101.     DragRegionMessage = INTEGER;
  102.  
  103.  
  104. { Zoom Acceleration }
  105.  
  106. CONST
  107.     zoomNoAcceleration            =    0;            { use linear interpolation }
  108.     zoomAccelerate                =    1;            { ramp up step size }
  109.     zoomDecelerate                =    2;            { ramp down step size }
  110.  
  111. TYPE
  112.     ZoomAcceleration = INTEGER;
  113.  
  114.  
  115. { Drag Manager Data Types }
  116.  
  117. TYPE
  118.     DragReference = LONGINT;
  119.     ItemReference = LONGINT;
  120.     
  121.     FlavorType = ResType;
  122.  
  123.  
  124. { Result Codes - (will move to Errors.p) }
  125.  
  126. CONST
  127.     badDragRefErr                =    -1850;        { unknown drag reference }
  128.     badDragItemErr                =    -1851;        { unknown drag item reference }
  129.     badDragFlavorErr            =    -1852;        { unknown flavor type }
  130.     duplicateFlavorErr            =    -1853;        { flavor type already exists }
  131.     cantGetFlavorErr            =    -1854;        { error while trying to get flavor data }
  132.     duplicateHandlerErr            =    -1855;        { handler already exists }
  133.     handlerNotFoundErr            =    -1856;        { handler not found }
  134.     dragNotAcceptedErr            =    -1857;        { drag was not accepted by receiver }
  135.  
  136.  
  137. { HFS Flavor }
  138.  
  139. TYPE
  140.     HFSFlavor = RECORD
  141.         fileType:                OSType;            { file type }
  142.         fileCreator:            OSType;            { file creator }
  143.         fdFlags:                INTEGER;        { Finder flags }
  144.         fileSpec:                FSSpec;            { file system specification }
  145.     END;
  146.  
  147.  
  148. { Promise HFS Flavor }
  149.  
  150. TYPE
  151.     PromiseHFSFlavor = RECORD
  152.         fileType:                OSType;            { file type }
  153.         fileCreator:            OSType;            { file creator }
  154.         fdFlags:                INTEGER;        { Finder flags }
  155.         promisedFlavor:            FlavorType;        { promised flavor containing FSSpec }
  156.     END;
  157.  
  158.  
  159. { Application-Defined Drag Handler Routines }
  160.  
  161. TYPE
  162.     DragTrackingHandler = ProcPtr;                { FUNCTION TrackingHandler    (message : DragTrackingMessage,
  163.                                                                              theWindow : WindowPtr,
  164.                                                                               handlerRefCon : Ptr,
  165.                                                                              theDragRef : DragReference) : OSErr; }
  166.     DragReceiveHandler = ProcPtr;                { FUNCTION ReceiveHandler    (theWindow : WindowPtr,
  167.                                                                              handlerRefCon : Ptr,
  168.                                                                              theDragRef : DragReference) : OSErr; }
  169.  
  170.  
  171. { Application-Defined Routines }
  172.  
  173. TYPE
  174.     DragSendDataProc = ProcPtr;                    { FUNCTION SendDataProc        (theType : FlavorType,
  175.                                                                              dragSendRefCon : Ptr,
  176.                                                                              theItemRef : ItemReference,
  177.                                                                              theDragRef : DragReference) : OSErr; }
  178.     DragInputProc = ProcPtr;                    { FUNCTION InputProc        (VAR mouse : Point,
  179.                                                                              VAR modifiers : INTEGER,
  180.                                                                              dragInputRefCon : Ptr,
  181.                                                                              theDragRef : DragReference) : OSErr; }
  182.     DragDrawingProc = ProcPtr;                    { FUNCTION DrawingProc        (message : DragRegionMessage,
  183.                                                                              showRegion : RgnHandle,
  184.                                                                              showOrigin : Point,
  185.                                                                              hideRegion : RgnHandle,
  186.                                                                              hideOrigin : Point,
  187.                                                                              dragDrawingRefCon : Ptr,
  188.                                                                              theDragRef : DragReference) : OSErr; }
  189.  
  190.  
  191. { Drag Manager Routines }
  192.  
  193.  
  194. { Installing and Removing Drag Handlers }
  195.  
  196. FUNCTION InstallTrackingHandler    (trackingHandler : DragTrackingHandler;
  197.                                  theWindow : WindowPtr;
  198.                                  handlerRefCon : UNIV Ptr) : OSErr;
  199.     INLINE $7001, $ABED;
  200.  
  201. FUNCTION InstallReceiveHandler    (receiveHandler : DragReceiveHandler;
  202.                                  theWindow : WindowPtr;
  203.                                  handlerRefCon : UNIV Ptr) : OSErr;
  204.     INLINE $7002, $ABED;
  205.  
  206. FUNCTION RemoveTrackingHandler    (trackingHandler : DragTrackingHandler;
  207.                                  theWindow : WindowPtr) : OSErr;
  208.     INLINE $7003, $ABED;
  209.  
  210. FUNCTION RemoveReceiveHandler    (receiveHandler : DragReceiveHandler;
  211.                                  theWindow : WindowPtr) : OSErr;
  212.     INLINE $7004, $ABED;
  213.  
  214.  
  215. { Creating and Disposing Drag References }
  216.  
  217. FUNCTION NewDrag                (VAR theDragRef : DragReference) : OSErr;
  218.     INLINE $7005, $ABED;
  219.  
  220. FUNCTION DisposeDrag            (theDragRef : DragReference) : OSErr;
  221.     INLINE $7006, $ABED;
  222.  
  223.  
  224. { Adding Drag Item Flavors }
  225.  
  226. FUNCTION AddDragItemFlavor        (theDragRef : DragReference;
  227.                                  theItemRef : ItemReference;
  228.                                  theType : FlavorType;
  229.                                  dataPtr : UNIV Ptr;
  230.                                  dataSize : Size;
  231.                                  theFlags : FlavorFlags) : OSErr;
  232.     INLINE $7007, $ABED;
  233.  
  234. FUNCTION AddHFSFlavor            (theDragRef : DragReference;
  235.                                  theItemRef : ItemReference;
  236.                                  fileSpec : FSSpec;
  237.                                  theFlags : FlavorFlags) : OSErr;
  238.     INLINE $7008, $ABED;
  239.  
  240. FUNCTION SetDragItemFlavorData    (theDragRef : DragReference;
  241.                                  theItemRef : ItemReference;
  242.                                  theType : FlavorType;
  243.                                  dataPtr : UNIV Ptr;
  244.                                  dataSize : Size;
  245.                                  dataOffset : LONGINT) : OSErr;
  246.     INLINE $7009, $ABED;
  247.  
  248.  
  249. { Providing Drag Callback Procedures }
  250.  
  251. FUNCTION SetDragSendProc        (theDragRef : DragReference;
  252.                                  sendProc : DragSendDataProc;
  253.                                  dragSendRefCon : UNIV Ptr) : OSErr;
  254.     INLINE $700A, $ABED;
  255.  
  256. FUNCTION SetDragInputProc        (theDragRef : DragReference;
  257.                                  inputProc : DragInputProc;
  258.                                  dragInputRefCon : UNIV Ptr) : OSErr;
  259.     INLINE $700B, $ABED;
  260.  
  261. FUNCTION SetDragDrawingProc        (theDragRef : DragReference;
  262.                                  drawingProc : DragDrawingProc;
  263.                                  dragDrawingRefCon : UNIV Ptr) : OSErr;
  264.     INLINE $700C, $ABED;
  265.  
  266.  
  267. { Performing a Drag }
  268.  
  269. FUNCTION TrackDrag                (theDragRef : DragReference;
  270.                                  theEvent : EventRecord;
  271.                                  theRegion : RgnHandle) : OSErr;
  272.     INLINE $700D, $ABED;
  273.  
  274.  
  275. { Getting Drag Item Information }
  276.  
  277. FUNCTION CountDragItems            (theDragRef : DragReference;
  278.                                  VAR numItems : INTEGER) : OSErr;
  279.     INLINE $700E, $ABED;
  280.  
  281. FUNCTION GetDragItemReferenceNumber
  282.                                 (theDragRef : DragReference;
  283.                                  index : INTEGER;
  284.                                  VAR theItemRef : ItemReference) : OSErr;
  285.     INLINE $700F, $ABED;
  286.  
  287. FUNCTION CountDragItemFlavors    (theDragRef : DragReference;
  288.                                  theItemRef : ItemReference;
  289.                                  VAR numFlavors : INTEGER) : OSErr;
  290.     INLINE $7010, $ABED;
  291.  
  292. FUNCTION GetFlavorType            (theDragRef : DragReference;
  293.                                  theItemRef : ItemReference;
  294.                                  index : INTEGER;
  295.                                  VAR theType : FlavorType) : OSErr;
  296.     INLINE $7011, $ABED;
  297.  
  298. FUNCTION GetFlavorFlags            (theDragRef : DragReference;
  299.                                  theItemRef : ItemReference;
  300.                                  theType : FlavorType;
  301.                                  VAR theFlags : FlavorFlags) : OSErr;
  302.     INLINE $7012, $ABED;
  303.  
  304. FUNCTION GetFlavorDataSize        (theDragRef : DragReference;
  305.                                  theItemRef : ItemReference;
  306.                                  theType : FlavorType;
  307.                                  VAR dataSize : Size) : OSErr;
  308.     INLINE $7013, $ABED;
  309.  
  310. FUNCTION GetFlavorData            (theDragRef : DragReference;
  311.                                  theItemRef : ItemReference;
  312.                                  theType : FlavorType;
  313.                                  dataPtr : UNIV Ptr;
  314.                                  VAR dataSize : Size;
  315.                                  dataOffset : LONGINT) : OSErr;
  316.     INLINE $7014, $ABED;
  317.  
  318. FUNCTION GetDragItemBounds        (theDragRef : DragReference;
  319.                                  theItemRef : ItemReference;
  320.                                  VAR itemBounds : Rect) : OSErr;
  321.     INLINE $7015, $ABED;
  322.  
  323. FUNCTION SetDragItemBounds        (theDragRef : DragReference;
  324.                                  theItemRef : ItemReference;
  325.                                  itemBounds : Rect) : OSErr;
  326.     INLINE $7016, $ABED;
  327.  
  328. FUNCTION GetDropLocation        (theDragRef : DragReference;
  329.                                  VAR dropLocation : AEDesc) : OSErr;
  330.     INLINE $7017, $ABED;
  331.  
  332. FUNCTION SetDropLocation        (theDragRef : DragReference;
  333.                                  dropLocation : AEDesc) : OSErr;
  334.     INLINE $7018, $ABED;
  335.  
  336.  
  337.  
  338. { Getting Information About a Drag }
  339.  
  340. FUNCTION GetDragAttributes        (theDragRef : DragReference;
  341.                                  VAR flags : DragAttributes) : OSErr;
  342.     INLINE $7019, $ABED;
  343.  
  344. FUNCTION GetDragMouse            (theDragRef : DragReference;
  345.                                  VAR mouse : Point;
  346.                                  VAR pinnedMouse : Point) : OSErr;
  347.     INLINE $701A, $ABED;
  348.  
  349. FUNCTION SetDragMouse            (theDragRef : DragReference;
  350.                                  pinnedMouse : Point) : OSErr;
  351.     INLINE $701B, $ABED;
  352.  
  353. FUNCTION GetDragOrigin            (theDragRef : DragReference;
  354.                                  VAR initialMouse : Point) : OSErr;
  355.     INLINE $701C, $ABED;
  356.  
  357. FUNCTION GetDragModifiers        (theDragRef : DragReference;
  358.                                  VAR modifiers : INTEGER;
  359.                                  VAR mouseDownModifiers : INTEGER;
  360.                                  VAR mouseUpModifiers : INTEGER) : OSErr;
  361.     INLINE $701D, $ABED;
  362.  
  363.  
  364. { Drag Highlighting }
  365.  
  366. FUNCTION ShowDragHilite            (theDragRef : DragReference;
  367.                                  hiliteFrame : RgnHandle;
  368.                                  inside : Boolean) : OSErr;
  369.     INLINE $701E, $ABED;
  370.  
  371. FUNCTION HideDragHilite            (theDragRef : DragReference) : OSErr;
  372.     INLINE $701F, $ABED;
  373.  
  374. FUNCTION DragPreScroll            (theDragRef : DragReference;
  375.                                  dH : INTEGER;
  376.                                  dV : INTEGER) : OSErr;
  377.     INLINE $7020, $ABED;
  378.  
  379. FUNCTION DragPostScroll            (theDragRef : DragReference) : OSErr;
  380.     INLINE $7021, $ABED;
  381.  
  382. FUNCTION UpdateDragHilite        (theDragRef : DragReference;
  383.                                  updateRgn : RgnHandle) : OSErr;
  384.     INLINE $7022, $ABED;
  385.  
  386.  
  387. { Drag Manager Utilities }
  388.  
  389. FUNCTION WaitMouseMoved            (initialMouse : Point) : BOOLEAN;
  390.     INLINE $7023, $ABED;
  391.  
  392. FUNCTION ZoomRects                (fromRect : Rect;
  393.                                  toRect : Rect;
  394.                                  zoomSteps : INTEGER;
  395.                                  acceleration : ZoomAcceleration) : OSErr;
  396.     INLINE $7024, $ABED;
  397.  
  398. FUNCTION ZoomRegion                (region : RgnHandle;
  399.                                  zoomDistance : Point;
  400.                                  zoomSteps : INTEGER;
  401.                                  acceleration : ZoomAcceleration) : OSErr;
  402.     INLINE $7025, $ABED;
  403.  
  404.  
  405. { Will move to TextEdit.p }
  406. FUNCTION TEGetHiliteRgn            (region : RgnHandle;
  407.                                  hTE : TEHandle) : OSErr;
  408.     INLINE $3F3C, $000F, $A83D;
  409.  
  410.  
  411. {$ENDC} { UsingDrag }
  412.  
  413. {$IFC NOT UsingIncludes}
  414.     END.
  415. {$ENDC}
  416.